package com.itheima.网络编程.tcp编程.tcp编程.tcp线程池案例四;

import java.io.*;
import java.net.Socket;
import java.util.UUID;

public class 线程 implements Runnable {
    Socket sk;

    public 线程(Socket sk) {
        this.sk = sk;
    }

    @Override
    public void run() {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(sk.getInputStream()));
            BufferedWriter bw = new BufferedWriter(new FileWriter("day16 网络编程\\"+ UUID.randomUUID().toString().substring(12) +"线程池.txt"));
            String str;
            while ((str = br.readLine()) != null) {
                bw.write(str);
                bw.newLine();
                bw.flush();
            }
//            sk.shutdownOutput();
            System.out.println("======================================");
            BufferedWriter bws=new BufferedWriter(new OutputStreamWriter(sk.getOutputStream()));
            bws.write("上传成功!");
            bws.flush();
            bws.close();
            bw.close();
            br.close();
            sk.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
